package team.sun.sss.dao.hardwork;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.sun.sss.pojo.hardwork.HwBatch;

import java.util.List;

@Mapper
@Repository
public interface HwBatchDao {

    @Select("select DISTINCT batch_team from hw_batch ")
    List<HwBatch>getTeamName();
    //1.显示所有批次表格
    @Select("select * from hw_batch ")
    List<HwBatch> getHwBatchList();
    //1.2
    @Select("select * from hw_batch where batch_num=#{batchNum}")
    List<HwBatch> getBatchByNum(int batchNum);

    @Select("select * from hw_batch where batch_team=#{batchTeam} and batch_state=#{batchState}")
    List<HwBatch> getBatchByTeam(String batchTeam,String batchState);
    //2.学工修改批次
    @Update("update hw_batch set batch_team=#{batchTeam},batch_state=#{batchState},batch_start_time=#{batchStartTime}," +
            "batch_end_time=#{batchEndTime},batch_write_time=#{batchWriteTime},batch_apply_start_time=#{batchApplyStartTime}," +
            "batch_apply_end_time=#{batchApplyEndTime} where batch_num=#{batchNum} ")
    int updateHwBatch(String batchTeam,String batchState,String batchStartTime,String batchEndTime,String batchWriteTime,
                      String batchApplyStartTime, String batchApplyEndTime,int batchNum);

    //3.学工发布批次
    @Insert("insert into hw_batch(batch_team,batch_state,batch_start_time,batch_end_time,batch_write_time,batch_apply_start_time,batch_apply_end_time) values" +
            "(#{batchTeam},#{batchState},#{batchStartTime},#{batchEndTime},#{batchWriteTime},#{batchApplyStartTime},#{batchApplyEndTime})")
    int addHwBatch(String batchTeam,String batchState,String batchStartTime,String batchEndTime,String batchWriteTime,String batchApplyStartTime,
                   String batchApplyEndTime);
    //4.学工删除批次
    @Delete("delete from hw_batch where batch_num=#{batchNum}")
    int deleteHwBatch( int batchNum);
}
